<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-8-13
 * Time: 上午9:17
 */

namespace webapi\modules\route\controllers;


use common\rewrite\deepziyu\yii_fast_api\models\Route;
use yii\web\Controller;

class ApiController extends Controller
{
    public function init()
    {
        parent::init();
        \Yii::$app->response->format = 'html';
    }

    /**
     * Displays homepage.
     * @param int $id
     * @return string
     */
    public function actionIndex()
    {
        $model = new Route();
        $routes =  $model->getRoutes();
        unset($routes['/*']);
        foreach ($routes as $key =>  &$route) {
            if(preg_match('#^/route|gii|debug/#',$key,$m)){
                unset($routes[$key]);
            }
        }
        $routes = array_reverse($routes);
        return $this->renderPartial('index',[
            'routes'=>$routes
        ]);
    }

    public function actionUseDoc()
    {
        return $this->renderPartial('use-doc');
    }
}